﻿<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:me="clr-namespace:Pronama.NamaTyping"
    xmlns:converter="clr-namespace:Pronama.NamaTyping.Converter"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" 
    x:Class="ScreenWindow"
    x:Name="ScreenWindow"
    SizeToContent="WidthAndHeight"
    Title="{Binding WindowTitle}" ResizeMode="CanMinimize">
    <Window.Resources>
        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
        <converter:TimeSpanToStringConverter x:Key="TimeSpanToStringConverter" />
        <converter:NegationBooleanToVisibilityConverter x:Key="NegationBooleanToVisibilityConverter" />
        <Storyboard x:Key="FadeStoryboard">
        	<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="StatusTextBox">
        		<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
        		<EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="1"/>
        		<EasingDoubleKeyFrame KeyTime="0:0:6.5" Value="1"/>
        		<EasingDoubleKeyFrame KeyTime="0:0:7.5" Value="0"/>
        	</DoubleAnimationUsingKeyFrames>
        </Storyboard>

    </Window.Resources>
	<Window.Triggers>
		<EventTrigger RoutedEvent="FrameworkElement.Loaded">
			<BeginStoryboard Storyboard="{StaticResource FadeStoryboard}"/>
		</EventTrigger>
	</Window.Triggers>

    <Grid x:Name="RootGrid">
    	<VisualStateManager.VisualStateGroups>
    		<VisualStateGroup x:Name="VisualStateGroup"/>
    	</VisualStateManager.VisualStateGroups>
        <!--<Grid.Resources>
            <ResourceDictionary Source="/presentationframework.Royale;component/themes/royale.normalcolor.xaml" />
        </Grid.Resources>-->

        <Grid.RowDefinitions>
        	<RowDefinition />
        	<RowDefinition Height="480" />
        	<RowDefinition />
        	<RowDefinition />
        	<RowDefinition />
        </Grid.RowDefinitions>

        <ToolBarPanel>            
            <ToolBar ToolBarTray.IsLocked="True">                
                <Grid>
                    
                        <TextBox Margin="5 0 0 0" x:Name="LiveIdTextBox" VerticalAlignment="Center" Width="100" Text="{Binding LiveProgramIdText, UpdateSourceTrigger=PropertyChanged}" />
                    
                        
                            <!--<TextBox.Background>
                                <VisualBrush TileMode="None" Stretch="None" AlignmentX="Left">
                                    <VisualBrush.Visual>
                                        <TextBlock Text="Live ID" Foreground="Gray"  />
                                    </VisualBrush.Visual>
                                </VisualBrush>
                            </TextBox.Background>-->
                    <!--<TextBox.Style>
                        <Style TargetType="TextBox">
                            <Style.Triggers>
                                <MultiDataTrigger>
                                    <MultiDataTrigger.Conditions>
                                        <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=Text.Length}" Value="0"/>
                                        <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsFocused}" Value="False"/>
                                    </MultiDataTrigger.Conditions>
                                    <Setter Property="Background">
                                        <Setter.Value>
                                            <VisualBrush TileMode="None" Stretch="None" AlignmentX="Left">
                                                <VisualBrush.Visual>
                                                    <TextBlock FontStyle="Italic" Text="Live ID" Foreground="Gray"  />
                                                </VisualBrush.Visual>
                                            </VisualBrush>
                                        </Setter.Value>
                                    </Setter>
                                </MultiDataTrigger>
                            </Style.Triggers>
                        </Style>
                    </TextBox.Style>-->


                </Grid>

                <ComboBox VerticalAlignment="Center" Width="100"
                                x:Name="CookieGetterComboBox"
                                SelectedItem="{Binding CookieSource}"/>
                <Button ToolTip="接続" x:Name="ConnectButton" Command="{Binding ConnectCommand}">
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                        <Image Source="Images/lightning.png" Width="16" Height="16" SnapsToDevicePixels="True" x:Name="Image1" />
                        <TextBlock Text="接続" VerticalAlignment="Center" Margin="5 0 5 0" />
                    </StackPanel>
                </Button>
                <Button ToolTip="切断" x:Name="DisconnectButton" Command="{Binding DisconnectCommand}">
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                        <Image Source="Images/lightning_cross.png" Width="16" Height="16" SnapsToDevicePixels="True" />
                        <TextBlock Text="切断" VerticalAlignment="Center" Margin="5 0 5 0" />
                    </StackPanel>
                </Button>

                <Separator Margin="5 0 5 0" />

                <ToggleButton ToolTip="最前面に表示" IsChecked="{Binding Topmost, ElementName=ScreenWindow}">
                    <Image Source="Images/pin.png" Width="16" Height="16" SnapsToDevicePixels="True" />
                </ToggleButton>
                
                <ToggleButton ToolTip="テスト ツールバーの表示" Margin="5 0 0 0"
                              x:Name="BarToggleButton">
                    <Image Source="Images/ui-status-bar.png" Width="16" Height="16" SnapsToDevicePixels="True" />
                </ToggleButton>

                <Separator Margin="5 0 5 0" />

                <Button ToolTip="設定" Command="{Binding ShowResultsCommand}">
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                        <Image Source="Images/report--pencil.png" Width="16" Height="16" SnapsToDevicePixels="True" />
                        <TextBlock Text="採点結果..." VerticalAlignment="Center" Margin="5 0 5 0" />
                    </StackPanel>
                </Button>
                
                <Button ToolTip="設定" Command="{Binding ShowSettingsCommand}">
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                        <Image Source="Images/gear.png" Width="16" Height="16" SnapsToDevicePixels="True" />
                        <TextBlock Text="設定..." VerticalAlignment="Center" Margin="5 0 5 0" />
                    </StackPanel>
                </Button>

            </ToolBar>

        </ToolBarPanel>
        <WindowsFormsHost Width="640" Height="480" Grid.Row="1"
                          x:Name="ScreenWindowsFormsHost"/>
        
        <ToolBarPanel Grid.Row="2">

            <ToolBar ToolBarTray.IsLocked="True">

                <Button ToolTip="ホーム" Command="{Binding GoHomeCommand}">
                    <Image VerticalAlignment="Center" Source="Images/home.png" Width="16" Height="16" SnapsToDevicePixels="True" x:Name="image2" />
                </Button>

                <Button ToolTip="開く" Command="{Binding LoadCommand}" Margin="5 0 0 0">
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                        <Image Source="Images/folder-open-document-music.png" Width="16" Height="16" SnapsToDevicePixels="True" />
                        <TextBlock Text="開く" VerticalAlignment="Center" Margin="5 0 5 0" />
                    </StackPanel>
                </Button>

                <Button ToolTip="開始" Command="{Binding PlayCommand}">
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                        <Image Source="Images/control.png" Width="16" Height="16" SnapsToDevicePixels="True" />
                        <TextBlock Text="開始" VerticalAlignment="Center" Margin="5 0 5 0" />
                    </StackPanel>
                </Button>

                <Button ToolTip="終了しランキングを表示します" Command="{Binding StopCommand}">
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                        <Image Source="Images/trophy.png" Width="16" Height="16" SnapsToDevicePixels="True" />
                        <TextBlock Text="終了" VerticalAlignment="Center" Margin="5 0 5 0" />
                    </StackPanel>
                </Button>

                <!--<Button ToolTip="ランキング・採点情報をアップロードします" IsEnabled="False">
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                        <Image Source="Images/arrow-curve-090-left.png" Width="16" Height="16" SnapsToDevicePixels="True" />
                        <TextBlock Text="アップロード" VerticalAlignment="Center" Margin="5 0 5 0" />
                    </StackPanel>
                </Button>-->

                <Separator Margin="5 0 0 0" />

                <TextBlock Text="{Binding PlayerPosition, Converter={StaticResource TimeSpanToStringConverter}}" Margin="5 0 5 0" VerticalAlignment="Center" />
                <TextBlock Text="/" Margin="0" VerticalAlignment="Center" />
                <TextBlock Text="{Binding MediaLength, Converter={StaticResource TimeSpanToStringConverter}}" Margin="5 0 5 0" VerticalAlignment="Center" />
                

                <StackPanel Orientation="Horizontal" VerticalAlignment="Center" ToolTip="音量" Margin="5 0 0 0">
                    <Image Source="Images/speaker-volume.png" Width="16" Height="16" SnapsToDevicePixels="True" />
                    <Slider Width="80" Margin="5 0 5 0" Value="{Binding Volume}" VerticalAlignment="Center" Maximum="1" Minimum="0" LargeChange="0.2" />
                </StackPanel>


            </ToolBar>

        </ToolBarPanel>
        
        <ToolBarPanel Grid.Row="3">

            <ToolBar ToolBarTray.IsLocked="True" Visibility="{Binding IsChecked, Converter={StaticResource BooleanToVisibilityConverter}, ElementName=BarToggleButton}">
                <Button ToolTip="置換後 歌詞表示" Command="{Binding ShowLyricCommand}">
                    <Image VerticalAlignment="Center" Source="Images/document-music-playlist.png" Width="16" Height="16" SnapsToDevicePixels="True" />
                </Button>

                <Separator Margin="5 0 0 0" />

                <Image VerticalAlignment="Center" Source="Images/balloon.png" Width="16" Height="16" SnapsToDevicePixels="True" Margin="5 0 0 0" />
                <TextBlock Text="コメント入力:" Margin="5 0 0 0" VerticalAlignment="Center" />
   
                <ComboBox SelectedIndex="1" VerticalAlignment="Center" Margin="5 0 0 0" Width="80" x:Name="UserComboBox">
                    <ComboBoxItem>
                        <StackPanel HorizontalAlignment="Left" VerticalAlignment="Center" Orientation="Horizontal">
                            <Image VerticalAlignment="Center" Source="Images/user-silhouette.png" Width="16" Height="16" SnapsToDevicePixels="True" />
                            <TextBlock VerticalAlignment="Center" Text="生主" Margin="3 0 0 0" />
                        </StackPanel>
                    </ComboBoxItem>
                    <ComboBoxItem>
                        <StackPanel x:Name="CasterComboBoxItem" HorizontalAlignment="Left" VerticalAlignment="Center" Orientation="Horizontal">
                            <Image VerticalAlignment="Center" Source="Images/user-silhouette.png" Width="16" Height="16" SnapsToDevicePixels="True" />
                            <TextBlock VerticalAlignment="Center" Text="User 1" Margin="3 0 0 0" />
                        </StackPanel>
                    </ComboBoxItem>
                    <ComboBoxItem>
                        <StackPanel HorizontalAlignment="Left" VerticalAlignment="Center" Orientation="Horizontal">
                            <Image VerticalAlignment="Center" Source="Images/user-silhouette.png" Width="16" Height="16" SnapsToDevicePixels="True" />
                            <TextBlock VerticalAlignment="Center" Text="User 2" Margin="3 0 0 0" />
                        </StackPanel>
                    </ComboBoxItem>
                    <ComboBoxItem>
                        <StackPanel HorizontalAlignment="Left" VerticalAlignment="Center" Orientation="Horizontal">
                            <Image VerticalAlignment="Center" Source="Images/user-silhouette.png" Width="16" Height="16" SnapsToDevicePixels="True" />
                            <TextBlock VerticalAlignment="Center" Text="User 3" Margin="3 0 0 0" />
                        </StackPanel>
                    </ComboBoxItem>
                    <ComboBoxItem>
                        <StackPanel HorizontalAlignment="Left" VerticalAlignment="Center" Orientation="Horizontal">
                            <Image VerticalAlignment="Center" Source="Images/user-silhouette.png" Width="16" Height="16" SnapsToDevicePixels="True" />
                            <TextBlock VerticalAlignment="Center" Text="User 4" Margin="3 0 0 0" />
                        </StackPanel>
                    </ComboBoxItem>
                    <ComboBoxItem>
                        <StackPanel HorizontalAlignment="Left" VerticalAlignment="Center" Orientation="Horizontal">
                            <Image VerticalAlignment="Center" Source="Images/user-silhouette.png" Width="16" Height="16" SnapsToDevicePixels="True" />
                            <TextBlock VerticalAlignment="Center" Text="User 5" Margin="3 0 0 0" />
                        </StackPanel>
                    </ComboBoxItem>
                </ComboBox>

                <TextBox x:Name="MessageTextBox"  Width="220" Margin="5 0 0 0" KeyDown="MessageTextBox_KeyDown" />

                <Button ToolTip="ファイルから入力" Margin="5 0 0 0" Click="CommentFromFileButton">
                    <Image VerticalAlignment="Center" Source="Images/script-text.png" Width="16" Height="16" SnapsToDevicePixels="True" />
                </Button>

                <Separator Margin="5 0 5 0" />

                <Button ToolTip="再生スピード" Click="SpeedButtonClick">
                    <Image Source="Images/metronome.png" Width="16" Height="16" SnapsToDevicePixels="True" />
                </Button>
                <StackPanel Orientation="Horizontal" VerticalAlignment="Center" ToolTip="再生スピード">
                    <Slider Width="80" Margin="5 0 5 0" Value="{Binding SpeedRatio}" VerticalAlignment="Center" Maximum="5" Minimum="0" LargeChange="0.2" />
                    <TextBlock Grid.Row="1" Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Left" Text="{Binding SpeedRatio, StringFormat=0.00}" />
                </StackPanel>


            </ToolBar>

        </ToolBarPanel>

        <StatusBar Grid.Row="4">
            <StatusBarItem x:Name="statusBarItem">
                <TextBox IsReadOnly="True" x:Name="StatusTextBox" Text="{Binding StatusMessage}"
                         BorderThickness="0" Background="Transparent" VerticalAlignment="Center">
                    <i:Interaction.Triggers>
                    	<i:EventTrigger EventName="TextChanged">
                    		<ei:ControlStoryboardAction Storyboard="{StaticResource FadeStoryboard}"/>
                    	</i:EventTrigger>
                    </i:Interaction.Triggers>
                </TextBox>
                <!--<TextBlock x:Name="textBlock" Text="{Binding StatusMessage, NotifyOnTargetUpdated=True}" >
                </TextBlock>-->
            </StatusBarItem>
        </StatusBar>

    </Grid>

</Window>
